package com.zxy.car.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.zxy.car.entity.BuycarEntity;
import com.zxy.car.service.BuycarService;
import com.zxy.common.utils.PageUtils;
import com.zxy.common.utils.R;



/**
 * 
 *
 * @author zxy
 * @email 1695483548@qq.com
 * @date 2022-04-15 10:01:02
 */
@RestController
@RequestMapping("car/buycar")
public class BuycarController {
    @Autowired
    private BuycarService buycarService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = buycarService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		BuycarEntity buycar = buycarService.getById(id);

        return R.ok().put("buycar", buycar);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody BuycarEntity buycar){
		buycarService.save(buycar);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody BuycarEntity buycar){
		buycarService.updateById(buycar);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		buycarService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
